<template>
  <common-dialog
    ref="dialog"
    width="800px"
    title="旧ICP客户详情"
    :inDialog="inDialog"
    :data="data"
  >
    <el-alert
      v-show="data.id!=data.mergerId"
      title="提示"
      type="warning"
      show-icon
      :closable="false"
    >
      该客户已被合并到其它客户中。<span
        class="c-link"
        @click="openMainCustomer"
      >[查看主客户]</span>
    </el-alert>
    <common-form
      ref="form"
      text-mode
      label-width="100px"
    >
      <el-divider>客户信息</el-divider>
      <el-row :gutter="10">
        <el-col :span="12">
          <el-form-item label="客户ID">{{data.id}}</el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="客户代码">{{data.code}}</el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="10">
        <el-col :span="24">
          <el-form-item label="英文名称">{{ data.eName }}</el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="中文名称">{{ data.cName }}</el-form-item>
        </el-col>        
        <el-col :span="24">
          <el-form-item label="英文地址">{{ data.eAddress }}</el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="中文地址">{{ data.cAddress }}</el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="电话1">{{ data.tel1 }}</el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="电话2">{{ data.tel2 }}</el-form-item>
        </el-col>
        <el-col :span="24">
          <el-form-item label="审批状态">{{ data.examineStateName }}</el-form-item>
        </el-col>
      </el-row>
      <el-row :gutter="10">
        <el-col :span="12">
          <el-form-item label="创建时间">{{ data.createDate }}</el-form-item>
        </el-col>
        <el-col :span="12">
          <el-form-item label="最后更新时间">{{ data.UpdateDate }}</el-form-item>
        </el-col>
      </el-row>
    </common-form>
    <old-icp-detail-dialog
      ref="oldIcpDetailDialog"
      in-dialog
    ></old-icp-detail-dialog>
  </common-dialog>
</template>
<script>
import commonDialog from "@/components/common/dialog";
import commonForm from "@/components/common/form";
import api from "@/api/crm/customer";

export default {
  props: {
    inDialog: {
      type: Boolean,
      default: false
    },
  },
  // mixins: [detailsDialogMixin],
  components: {
    commonDialog,
    commonForm
  },
  data() {
    return {
      data: {
        id: "",
        name: "",
        mergerId: "",
        code: "",
        enName: "",
        zhName: ""
      },
      tabName: "location",
      api,
    };
  },
  created() {
    this.$options.components.oldIcpDetailDialog = () => import('./oldIcpDetailDialog')
  },
  methods: {
    openDetail(id) {
      this.$refs.dialog.open().then(() => {
        this.getData(id);
      });
    },
    getData(id) {
      this.$refs.dialog.loading(true);
      api.getOldIcpDetail(id).then((res) => {
        this.$refs.dialog.loading(false);
        if (res.code != 0) {
          return;
        }
        this.data = res.data;
      });
    },
    openMainCustomer() {
      this.$refs.oldIcpDetailDialog.openDetail(this.data.mergerId);
    },
  },
};
</script>